using System;
using System.Net;


namespace Weathertastic
{
   /// <summary>
	/// Downloads a file from the given url and saves it as the given filename.
	/// </summary>
    public class DownloadFile
    {
        public DownloadFile()
        {
        }

        public bool Download(string sURL, string sFileName)
        {
            try
            {
                WebProxy proxy = new WebProxy();
                proxy.UseDefaultCredentials = true;

                WebClient client = new WebClient();
                client.Proxy = proxy;
                client.DownloadFile(sURL, sFileName);
            }
            catch (Exception exc)
            {
                // Read/write errror
                return false;
            }

            return true;
        }
    }
}
